#include"lottery_sys.h"
void sort_money(Buyer_t* user_head)
{ 
//	printf("排序前：\n");
//	show_user_list(user_head);
	int count = 0;
	Buyer_t* cur = NULL;
	Buyer_t* arr = NULL;
	cur = user_head-> next;
	while(cur != NULL)
	{
		count++;
		cur = cur -> next;
	}
	arr = calloc(count,sizeof(Buyer_t));
	if(NULL == arr)
	{
		return;
	}
	count = 0;
	cur = user_head-> next;
	while(cur != NULL)
	{
		arr[count] = *cur;
		count++;
		cur = cur -> next;
	}
	qsort(arr,count,sizeof(Buyer_t),myCmp_money);
	show_arr(arr,count);
	free(arr);
}

int myCmp_money(const void* pa,const void* pb)
{
	Buyer_t* a = (Buyer_t* )pa;
	Buyer_t* b = (Buyer_t* )pb;
	return ((a -> B_remain_money) - (b -> B_remain_money));
}
